#include<iostream>
#include<vector>
#include<unordered_map>
using namespace std;



int subarraysDivByK(vector<int>& nums, int k) {
    unordered_map<int, int> hash;
    int sum = 0, ret = 0;
    hash[0] = 1;

    for (auto x : nums)
    {
        sum += x;
        int r = (sum % k + k) % k;
        if (hash.count(r)) ret += hash[r];
        hash[r]++;
    }
    return ret;
}


int main()
{

    vector<int> v = { 4,5,0,-2,-3,1 };
    subarraysDivByK(v,5);
    return 0;

}